package com.xsmart.oa.api;

import com.xsmart.common.entity.RequestBean;
import com.xsmart.common.entity.ResponseBean;
import com.xsmart.oa.services.DistributorManageService;
import com.xsmart.oa.services.DistributorService;
import com.xsmart.oa.services.QueryDistributorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/11/23.
 */
@Controller
@RequestMapping("/api")
public class DistributorManageController {
    @Autowired
    QueryDistributorService queryDistributorService;
    @Autowired
    DistributorService distributorService;
    @Autowired
    DistributorManageService distributorManageService;

    @RequestMapping(value="/v1/queryDistributor/queryAllDistributor",method = RequestMethod.POST)
    @ResponseBody
    public Object queryAllDistributor(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return queryDistributorService.queryDistributor(requestBean);
    }
    @RequestMapping(value="/v1/queryPassAndUnPass/queryPassAndUnPassDistributor",method = RequestMethod.POST)
    @ResponseBody
    public Object queryPassAndUnPassDistributor(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return queryDistributorService.queryPassAndUnPass(requestBean);
    }
    @RequestMapping(value="v1/examineDistributor/examineDistri",method = RequestMethod.POST)
    @ResponseBody
    public Object examineDistri(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return queryDistributorService.updateDistributor(requestBean);
    }
    @RequestMapping(value = "v1/examineSupplier/examineSupp",method = RequestMethod.POST)
    public Object examineSupp(@ModelAttribute RequestBean requestBean,HttpServletRequest httpServletRequest){
        return queryDistributorService.updateDistributor(requestBean);
    }
    @RequestMapping(value="v1/newExamineDistributor/examineDistri",method = RequestMethod.POST)
    @ResponseBody
    public Object examineDistributor(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return queryDistributorService.newUpdateDistributor(requestBean);
    }

    /**
     * 会员绑定分销商
     * @param requestBean 请求对象
     * @param httpServletRequest 请求对象
     * @return 绑定结果
     */
    @RequestMapping(value = "v1/DistributorService/distributorMemberRel",method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean distributorMemberRel(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return distributorService.distributorMemberRel(requestBean);
    }

    /**
     * 会员分享记录
     * @param requestBean 请求对象
     * @param httpServletRequest 请求对象
     * @return 分享保存结果
     */
    @RequestMapping(value = "v1/DistributorService/shareLog",method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean shareLog(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return distributorService.shareLog(requestBean);
    }

    /**
     * 分销商管理页面-查询所有分销商
     *
     * @author xiaofeng
     * @param requestBean 请求对象
     * @param httpServletRequest 请求对象
     * @return 绑定结果
     */
    @RequestMapping(value = "v1/DistributorManageService/queryAllDistributorManage",method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean queryAllDistributorManage(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return distributorManageService.queryDistributor(requestBean);
    }

    /**
     * 分销商管理页面-修改分销商信息分销商
     *
     * @author xiaofeng
     * @param requestBean 请求对象
     * @param httpServletRequest 请求对象
     * @return 绑定结果
     */
    @RequestMapping(value = "v1/DistributorManageService/updateDistributorManage",method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean updateDistributorManage(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return distributorManageService.updateDistributor(requestBean);
    }

    /**
     *分销商管理页面-修改分销商对应商店信息
     *
     * @author xxf
     * @param requestBean 请求对象
     * @param httpServletRequest 请求对象
     * @return 绑定结果
     * @date 2018/3/5
     */
    @RequestMapping(value = "v1/DistributorManageService/updateDistributorShopInfo",method = RequestMethod.POST)
    @ResponseBody
    public ResponseBean updateDistributorShopInfo(@ModelAttribute RequestBean requestBean, HttpServletRequest httpServletRequest){
        return distributorManageService.editShopInfo(requestBean);
    }
}
